﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing.Design;
using System.Windows.Forms.Design;
using UIDesign;
using System.Windows.Forms;
using System.ComponentModel;

namespace UIMarker
{
    public class FrmItem : UITypeEditor
    {
        public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context)
        {
            if (context != null && context.Instance != null)
            {
                return UITypeEditorEditStyle.Modal;
            }

            return base.GetEditStyle(context);
        }

        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            IWindowsFormsEditorService editorService = null;

            if (context != null && context.Instance != null && provider != null)
            {
                editorService = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
                if (editorService != null)
                {
                    ItemLabel control = (ItemLabel)context.Instance;
                    //FrmItemEdit dlg = new FrmItemEdit();//control.TLayout
                    //if (dlg.ShowDialog() == DialogResult.OK)
                    {
                        //value = dlg.syLayout;
                        //control.ControlStr = MainHelp.LIST[Array.IndexOf(MainHelp.SLIST, dlg.syLayout.Controltype)];
                        //control.Text = dlg.syLayout.Columnname; //刷新页面上的Text
                        return value;
                    }
                }
            }

            return value;
        }
    }

}
